/**
 * Essay路由
 * 定义作文相关的API端点
 */

import express from 'express';
import * as essayController from '../controllers/essayController.js';
import { authenticate } from '../middlewares/auth.js';

const router = express.Router();

// ==================== Essay路由 ====================

/**
 * @route   POST /api/v1/essays
 * @desc    创建作文
 * @access  Private (需要认证)
 */
router.post('/', authenticate, essayController.createEssay);

/**
 * @route   GET /api/v1/essays/:essayId
 * @desc    获取作文详情
 * @access  Private (需要认证)
 */
router.get('/:essayId', authenticate, essayController.getEssayById);

/**
 * @route   GET /api/v1/essays/user/:userId
 * @desc    获取用户作文列表
 * @access  Private (需要认证)
 */
router.get('/user/:userId', authenticate, essayController.getUserEssays);

/**
 * @route   PUT /api/v1/essays/:essayId
 * @desc    更新作文
 * @access  Private (需要认证)
 */
router.put('/:essayId', authenticate, essayController.updateEssay);

/**
 * @route   DELETE /api/v1/essays/:essayId
 * @desc    删除作文
 * @access  Private (需要认证)
 */
router.delete('/:essayId', authenticate, essayController.deleteEssay);

export default router;

